package com.css.common.core.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 个人所得税项目
 */
@Getter
@AllArgsConstructor
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum GrsdsxmEnum {

    SWCDF_JYSD("01", 2, "经营所得"),
    SWCDF_LWBC("02", 3, "劳务报酬"),
    SWCDF_GC("03", 5, "稿酬"),
    SWCDF_TXQSYF("04", 4, "特许权使用费"),
    GRSDSXM_CCZRSD("05", 1, "财产转让所得"),
    GRSDSXM_QT("06", 6, "其他");

    private final String dm;
    private final Integer zfjkpDm;//乐企代码
    private final String mc;

    public static String getMc(String dm) {
        GrsdsxmEnum res = Arrays.stream(values())
                .filter(x -> x.getDm().equals(dm))
                .findFirst().orElse(null);
        return res == null ? null : res.getMc();
    }

    public static GrsdsxmEnum getInstance(String dm) {
        for (GrsdsxmEnum grsdsxmEnum : values()) {
            if (grsdsxmEnum.getDm().equals(dm)) {
                return grsdsxmEnum;
            }
        }
        return GRSDSXM_QT;
    }
}
